package basic5;

import java.util.Scanner;

public class J05_53 {

	public static void main(String[] args) {
		int year;
		int day;
	
		Scanner sc=new Scanner(System.in);
		System.out.print("년도를 입력 하세요 : ");
		year=sc.nextInt();
		
		
		day=(((((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400)%7)+1))%7;
		
		
		
//		System.out.println(day);
			
		for(int i=1; i<=31+day; ++i){
			
			if (i < day){
				System.out.print("\t");
				
			} else if (day >= 0){
				System.out.print((i-day)+"\t");
				if (i%7==0) {
					System.out.println();
				}
				
			}else if (i%day==0){
				System.out.println();
			}
			
		
		}
			
		
		

	}

}
